package com.solution.admin.customer.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.solution.admin.customer.dao.CustomerTypeDao;
import com.solution.admin.customer.entity.CustomerTypeEntity;
import com.solution.admin.customer.service.CustomerTypeService;
import com.solution.admin.settings.dao.SortDao;
import com.solution.common.dao.BaseDao;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;
import com.solution.common.service.impl.BaseServiceImpl;

/**
 * 客户类型配置service实现层
 * @author solin
 * @date 2017-09-16 23:38:50
 */
@Service
public class CustomerTypeServiceImpl extends BaseServiceImpl<CustomerTypeEntity> implements CustomerTypeService {

	/**
	 * 客户类型配置接口
	 */
	@Autowired
	private CustomerTypeDao ebCustomerTypeDao;
	@Autowired
	private SortDao sortDao;

	protected BaseDao<CustomerTypeEntity> getDao() {
		return this.ebCustomerTypeDao;
	}

	/**
	 * 保存客户类型配置
	 * @param ebCustomerTypeEntity 客户类型配置实体
	 * @return Long 添加成功客户类型配置的ID
	 * @author solin
	 * @date 2017-09-16 23:38:50
	 */
	public long saveEbCustomerType(CustomerTypeEntity ebCustomerTypeEntity) {
		ebCustomerTypeEntity.setSortNo(sortDao.getMaxSortNo("eb_customer_type") + 1);
		return ebCustomerTypeDao.saveEbCustomerType(ebCustomerTypeEntity);
	}

	/**
	 * 分页查询客户类型配置
	 * @param pageParam 分页参数
	 * @param paramMap 查询参数
	 * @return PageBean 分页参数和分页数据
	 * @author solin
	 * @date 2017-09-16 23:38:50
	 */
	@Override
	public PageBean listEbCustomerTypePage(PageParam pageParam, Map<String, Object> paramMap) {
		return ebCustomerTypeDao.listEbCustomerTypePage(pageParam, paramMap);
	}
	
	/**
	 * 根据ID查询用户信息
	 * @param id 用户id
	 * @return ebCustomerTypeEntity 用户对象
	 * @author solin
	 * @date 2017-09-16 23:38:50
	 */
	public CustomerTypeEntity getEbCustomerTypeById(Long id) {
		return ebCustomerTypeDao.getById(id.longValue());
	}

	/**
	 * 更新用户
	 * @param ebCustomerTypeEntity 用户实体
	 * @return Long 更新是否成功，>1代表更新成功
	 * @author solin
	 * @date 2017-09-16 23:38:50
	 */
	@Override
	public int updateEbCustomerType(CustomerTypeEntity ebCustomerTypeEntity) {
		return ebCustomerTypeDao.updateEbCustomerType(ebCustomerTypeEntity);
	}
	
	
	/**
	 * 根据条件查询客户类型配置
	 * @param param
	 * @return 数据列表
	 * @author solin
	 * @date 2017-09-16 23:38:50
	 */
	@Override
	public List<CustomerTypeEntity> listEbCustomerType( Map<String, Object> param){
		return  ebCustomerTypeDao.listEbCustomerType(param);
	}
	
	/**
	 * 删除客户类型配置
	 * @param 
	 * @return int 返回删除记录条数
	 * @author solin
	 * @date 2017-09-16 23:38:50
	 */
	public int deleteEbCustomerTypeById(long id){
		return  ebCustomerTypeDao.deleteById(id);
	}
	
}
